<template>
    <div class="app-container">
        <el-row :gutter="20">
            <el-col :span="4">
                <div class="equipment-tree-container">
                    <!-- 顶部标题 -->
                    <div class="header" @click="handlerChargeStation">
                        <h2>激光产业园1栋</h2>
                    </div>

                    <!-- 设备树 -->
                    <div class="equipment-tree">
                        <!-- 逆变器 -->
                        <div class="tree-node">
                            <div class="node-header" @click="toggleNode('inverter')">
                                <div class="node-icon">⚡</div>
                                <div class="node-title">
                                    <span>逆变器</span>
                                    <span class="device-count">({{ inverterList.length }})</span>
                                </div>
                                <div class="collapse-icon" :class="{ rotated: expandedNodes.inverter }">
                                    ▼
                                </div>
                            </div>
                            <div class="node-children" v-show="expandedNodes.inverter">
                                <div v-for="device in inverterList" :key="device.id" class="device-item"
                                    :class="{ active: selectedDevice === device.id }" @click="selectDevice(device)">
                                    <div class="device-sn">{{ device.sn }}</div>
                                    <div class="device-status" :class="device.status"></div>
                                </div>
                            </div>
                        </div>

                        <!-- 储能 -->
                        <div class="tree-node">
                            <div class="node-header" @click="toggleNode('storage')">
                                <div class="node-icon">🔋</div>
                                <div class="node-title">
                                    <span>储能</span>
                                    <span class="device-count">(0)</span>
                                </div>
                                <div class="collapse-icon" :class="{ rotated: expandedNodes.storage }">
                                    ▼
                                </div>
                            </div>
                            <div class="node-children" v-show="expandedNodes.storage">
                                <div class="empty-device">暂无设备</div>
                            </div>
                        </div>

                        <!-- 通讯网关 -->
                        <div class="tree-node">
                            <div class="node-header" @click="toggleNode('gateway')">
                                <div class="node-icon">📡</div>
                                <div class="node-title">
                                    <span>通讯网关</span>
                                    <span class="device-count">({{ gatewayList.length }})</span>
                                </div>
                                <div class="collapse-icon" :class="{ rotated: expandedNodes.gateway }">
                                    ▼
                                </div>
                            </div>
                            <div class="node-children" v-show="expandedNodes.gateway">
                                <div v-for="device in gatewayList" :key="device.id" class="device-item"
                                    :class="{ active: selectedDevice === device.id }" @click="selectDevice(device)">
                                    <div class="device-sn">{{ device.sn }}</div>
                                    <div class="device-status" :class="device.status"></div>
                                </div>
                            </div>
                        </div>

                        <!-- 其他设备 -->
                        <div v-for="category in otherCategories" :key="category.id" class="tree-node">
                            <div class="node-header" @click="toggleNode(category.id)">
                                <div class="node-icon">{{ category.icon }}</div>
                                <div class="node-title">
                                    <span>{{ category.name }}</span>
                                    <span class="device-count">(0)</span>
                                </div>
                                <div class="collapse-icon" :class="{ rotated: expandedNodes[category.id] }">
                                    ▼
                                </div>
                            </div>
                            <div class="node-children" v-show="expandedNodes[category.id]">
                                <div class="empty-device">暂无设备</div>
                            </div>
                        </div>
                    </div>

                    <!-- 选中设备信息 -->
                    <div class="selected-info" v-if="selectedDeviceData">
                        <h3>设备信息</h3>
                        <div class="info-content">
                            <div class="info-item">
                                <label>序列号：</label>
                                <span>{{ selectedDeviceData.sn }}</span>
                            </div>
                            <div class="info-item">
                                <label>类型：</label>
                                <span>{{ selectedDeviceData.type }}</span>
                            </div>
                            <div class="info-item">
                                <label>状态：</label>
                                <span :class="selectedDeviceData.status">{{ selectedDeviceData.statusText }}</span>
                            </div>
                        </div>
                    </div>
                </div>
            </el-col>
            <el-col :span="20">
                <el-tabs v-model="activeName" type="card" @tab-click="handleClick" v-if="selectedDevice == 'stationId'">
                    <el-tab-pane :label="`概况`" name="overview">
                        <div class="data-cards-container">
                            <!-- 实时功率卡片 -->
                            <div class="data-card power-card">
                                <div class="card-header">
                                    <div class="card-title">实时功率</div>
                                    <div class="card-unit">kW</div>
                                </div>
                                <div class="card-content">
                                    <div class="main-value">
                                        {{ data.power.value }}
                                        <span class="trend-indicator" :class="data.power.trend">
                                            {{ data.power.trend === 'rise' ? '↑' : '↓' }}
                                        </span>
                                    </div>
                                    <div class="card-details">
                                        <div class="detail-item">
                                            <span class="label">装机容量</span>
                                            <span class="value">{{ data.power.capacity }} kWp</span>
                                        </div>
                                        <div class="time-info">
                                            <span class="time-label">今日</span>
                                            <span class="time-value">{{ data.power.todayHours }}h</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 当日发电卡片 -->
                            <div class="data-card daily-card">
                                <div class="card-header">
                                    <div class="card-title">当日发电量</div>
                                </div>
                                <div class="card-content">
                                    <div class="main-value daily">
                                        {{ data.daily.generation }}
                                        <span class="value-unit">kW·h</span>
                                    </div>
                                    <div class="card-details">
                                        <div class="detail-item">
                                            <span class="label">当日收益</span>
                                            <span class="value">{{ data.daily.income }}元</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 本月发电卡片 -->
                            <div class="data-card monthly-card">
                                <div class="card-header">
                                    <div class="card-title">本月发电量</div>
                                </div>
                                <div class="card-content">
                                    <div class="main-value monthly">
                                        {{ data.monthly.generation }}
                                    </div>
                                    <div class="card-details">
                                        <div class="detail-item">
                                            <span class="label">本月收益</span>
                                            <span class="value">{{ data.monthly.income }}元</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 本月发电卡片 -->
                            <div class="data-card monthly-card">
                                <div class="card-header">
                                    <div class="card-title">本月发电量</div>
                                </div>
                                <div class="card-content">
                                    <div class="main-value monthly">
                                        {{ data.monthly.generation }}
                                    </div>
                                    <div class="card-details">
                                        <div class="detail-item">
                                            <span class="label">本月收益</span>
                                            <span class="value">{{ data.monthly.income }}元</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <el-row :gutter="20">
                            <el-col :span="18">
                                <div class="weather-power-card">
                                    <!-- 天气信息部分 -->
                                    <div class="weather-section">
                                        <!-- 今天天气 -->
                                        <div class="weather-today">
                                            <div class="temperature-range">
                                                <!-- 天气详情 -->
                                                <div class="weather-detail">
                                                    <span class="date">今天</span>
                                                    <span class="weather">| 晴</span>
                                                    <div>18 ~ 32℃</div>
                                                    <div class="wind-info">风向: 东北, 风力: 1-3</div>
                                                    <div class="timestamp">2025-10-10 14:31:25</div>
                                                </div>
                                                <!-- 未来天气 -->
                                                <div class="future-weather">
                                                    <div class="future-item">
                                                        <div class="temp-range">19 ~ 30℃</div>
                                                        <div class="weather-desc">明天 | 晴</div>
                                                    </div>
                                                    <div class="future-item">
                                                        <div class="temp-range">17 ~ 31℃</div>
                                                        <div class="weather-desc">后天 | 晴</div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="weather-info">
                                                <!-- 防逆流信息 -->
                                                <div class="reverse-flow">
                                                    <span class="reverse-flow-text">防逆流</span>
                                                    <span class="reverse-flow-value">1 ></span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <!-- 电力信息部分 -->
                                    <div class="power-section">
                                        <!-- 功率和占比 -->
                                        <div class="power-solar">
                                            <el-image :src="solarPanelUrl" class="power-image" />
                                        </div>
                                        <div class="power-line">
                                            <div class="power-line-inner"></div>
                                        </div>
                                        <div>
                                            <el-image :src="inverterUrl" class="power-image" />
                                        </div>
                                        <div class="power-line1">
                                            <div class="power-line1-horizontal">
                                                <div class="power-line1-horizontal-inner"></div>
                                            </div>
                                            <div class="power-line1-ordinate"></div>
                                            <div class="power-line1-ordinate1">
                                                <div class="power-line1-ordinate1-inner"></div>
                                            </div>
                                        </div>
                                        <div class="power-wire">
                                            <div>
                                                <el-image :src="wireBracketUrl" class="power-image" />
                                            </div>
                                            <div>
                                                <el-image :src="homeUrl" class="power-image" />
                                            </div>
                                        </div>
                                        <!-- <div class="power-main">
                            <div class="power-value">65.79 kW / 1600 kWp</div>
                            <div class="power-percentage">4.1%</div>
                        </div> -->
                                        <!-- 功率显示 -->
                                        <!-- <div class="power-display">
                            <div class="power-zero">0 kW</div>
                            <div class="power-current">65.79 kW</div>
                        </div> -->
                                    </div>
                                </div>
                                <div class="solar-panel-card">
                                    <!-- 电量信息 -->
                                    <div class="time_type">
                                        <el-radio-group v-model="typeOfElectricity" @input="handleChangeTimeType">
                                            <el-radio-button label="日"></el-radio-button>
                                            <el-radio-button label="月"></el-radio-button>
                                            <el-radio-button label="年"></el-radio-button>
                                            <el-radio-button label="总"></el-radio-button>
                                        </el-radio-group>

                                        <div class="block">
                                            <el-date-picker v-if="timeType" v-model="timeDate" :type="timeType"
                                                placeholder="选择日期">
                                            </el-date-picker>
                                        </div>
                                    </div>
                                    <el-row>
                                        <el-col :span="6">
                                            <PowerGenerateEchart />
                                        </el-col>
                                        <el-col :span="5" class="power_generate">
                                            <div>
                                                <div>0度(0%)</div>
                                                <div>流向电网</div>
                                            </div>
                                            <div>
                                                <div>0度(0%)</div>
                                                <div>流向电网</div>
                                            </div>
                                            <div>
                                                <div>0度(0%)</div>
                                                <div>流向电网</div>
                                            </div>
                                        </el-col>
                                        <el-col :span="2" class="time-line-info">
                                            <div class="time-line"></div>
                                        </el-col>
                                        <el-col :span="5" class="power_generate">
                                            <div>
                                                <div>0度(0%)</div>
                                                <div>流向电网</div>
                                            </div>
                                            <div>
                                                <div>0度(0%)</div>
                                                <div>流向电网</div>
                                            </div>
                                            <div>
                                                <div>0度(0%)</div>
                                                <div>流向电网</div>
                                            </div>
                                        </el-col>
                                        <el-col :span="6">
                                            <PowerGenerateEchart />
                                        </el-col>
                                    </el-row>
                                    <div class="time_type" style="justify-content: center;color:#000">
                                        <div class="block">
                                            日发电量: 208.01 度
                                        </div>
                                        <div class="block">
                                            日收益: 0 元
                                        </div>
                                        <div class="block">
                                            日满发小时: 0.52 h
                                        </div>
                                    </div>
                                    <el-row>
                                        <el-col :span="24">
                                            <PowerLevelEchart v-if="typeOfElectricity == '日'" />
                                            <PowerLevelBarEchart v-if="typeOfElectricity !== '日'" :dates="dates" />
                                        </el-col>
                                    </el-row>
                                </div>
                                <div class="solar-panel-card">
                                    <!-- 环保收益 -->
                                    <div class="environmental_text">
                                        环保收益
                                    </div>
                                    <div class="environmental">
                                        <div class="environmental_content">
                                            <el-image :src="treeUrl" class="environmental_image" />
                                            <div class="environmental_img_text">
                                                <div><span>78435.43</span> kg</div>
                                                <div>累计节煤量</div>
                                            </div>
                                        </div>
                                        <div class="environmental_content">
                                            <el-image :src="co2Url" class="environmental_image" />
                                            <div class="environmental_img_text">
                                                <div><span>19.55</span> t</div>
                                                <div>累计减排</div>
                                            </div>
                                        </div>
                                        <div class="environmental_content">
                                            <el-image :src="meiUrl" class="environmental_image" />
                                            <div class="environmental_img_text">
                                                <div><span>10588.78</span> 棵</div>
                                                <div>等效植树</div>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </el-col>
                            <el-col :span="6">
                                <div class="solar-panel-card">
                                    <!-- 光伏信息 -->
                                    <el-image :src="solarPanelImageUrl" class="solar-panel-image" />
                                    <div>电站名称:<span>聚贤科技产业园物业楼</span></div>
                                    <div>电站类型:<span>工商业光伏</span></div>
                                    <div>装机容量:<span>1600 kWp</span></div>
                                    <div>并网日期:<span>2025-08-28</span></div>
                                    <div>所在时区:<span>+08:00</span></div>
                                    <div>电站地址:<span>湖北省孝感市孝南区孝感开发区孝天街道聚贤科技产业园</span></div>
                                    <div>业主用户名:<span>高创光伏电站</span></div>
                                    <div>渠道商:<span>---</span></div>
                                    <div>联系电话:<span>13986485672</span></div>
                                </div>
                                <div class="solar-panel-card">
                                    <!-- 报警信息 -->
                                    <div class="alarm_info_text">
                                        <div class="alarm_title">报警信息</div>
                                        <div class="weather-info">
                                            <!-- 防逆流信息 -->
                                            <div class="reverse-flow">
                                                <span class="reverse-flow-text">更多 ></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="alarm_info" v-for="value in 3">
                                        <div class="alarm_info_detail">
                                            <div class="alarm_tags">
                                                <el-tag>标签一</el-tag>
                                                <span class="alarm_tags_text">30100201A00236H00116</span>
                                            </div>
                                            <span>电网异常</span>
                                            <span style="color: #666666;">2025-10-14 06:16:31</span>
                                        </div>
                                    </div>
                                </div>
                            </el-col>
                        </el-row>
                    </el-tab-pane>
                    <el-tab-pane :label="`资料`" name="information">
                        <Information />
                    </el-tab-pane>
                    <el-tab-pane :label="`设备`" name="equipment">
                        <Equipment />
                    </el-tab-pane>
                    <el-tab-pane :label="`报警`" name="alarmInfo">
                        <AlarmInfo />
                    </el-tab-pane>
                </el-tabs>
                <el-tabs v-model="activeName" type="card" @tab-click="handleClick"
                    v-if="selectedDevice !== 'stationId'">
                    <el-tab-pane :label="`设备概况`" name="overview">
                        <EquipmentOverview />
                    </el-tab-pane>
                    <el-tab-pane :label="`历史数据`" name="information">
                        <Information />
                    </el-tab-pane>
                    <el-tab-pane :label="`报警信息`" name="equipment">
                        <Equipment />
                    </el-tab-pane>
                    <el-tab-pane :label="`组串监控`" name="alarmInfo">
                        <AlarmInfo />
                    </el-tab-pane>
                </el-tabs>

            </el-col>
        </el-row>
    </div>
</template>

<script>
import PowerGenerateEchart from './powerGenerateEchart.vue';
import PowerLevelEchart from './powerLevelEchart.vue';
import PowerLevelBarEchart from './powerLevelBarEchart.vue';
import Information from './information.vue';
import Equipment from './equipment.vue';
import AlarmInfo from './alarmInfo.vue';
// 设备概况
import EquipmentOverview from './EquipmentOverview.vue';
export default {
    name: 'EquipmentTree',
    components: { PowerGenerateEchart, PowerLevelEchart, PowerLevelBarEchart, Information, Equipment, AlarmInfo, EquipmentOverview },
    data() {
        return {
            treeUrl: require('../../../assets/images/tree.png'),
            meiUrl: require('../../../assets/images/jiemei.png'),
            co2Url: require('../../../assets/images/co2.png'),
            expandedNodes: {
                inverter: true,
                storage: false,
                gateway: true,
                datacollector: false,
                meter: false,
                weather: false,
                transformer: false,
                pcs: false,
                power: false,
                locator: false
            },
            selectedDevice: 'stationId',
            selectedDeviceData: null,
            inverterList: [
                {
                    id: 'inv001',
                    sn: '30090558A00241H23332',
                    type: '逆变器',
                    status: 'normal',
                    statusText: '正常'
                },
                {
                    id: 'inv002',
                    sn: '30090558A00241H23335',
                    type: '逆变器',
                    status: 'normal',
                    statusText: '正常'
                },
                {
                    id: 'inv003',
                    sn: '30090558A00241H23393',
                    type: '逆变器',
                    status: 'normal',
                    statusText: '正常'
                }
            ],
            gatewayList: [
                {
                    id: 'gw001',
                    sn: '30081295A04243H53991',
                    type: '通讯网关',
                    status: 'normal',
                    statusText: '正常'
                },
                {
                    id: 'gw002',
                    sn: '30081295A04243H54031',
                    type: '通讯网关',
                    status: 'normal',
                    statusText: '正常'
                },
                {
                    id: 'gw003',
                    sn: '30081295A04243H54743',
                    type: '通讯网关',
                    status: 'normal',
                    statusText: '正常'
                }
            ],
            otherCategories: [
                { id: 'datacollector', name: '数采器', icon: '📊' },
                { id: 'meter', name: '电表', icon: '🔢' },
                { id: 'weather', name: '气象仪', icon: '🌤️' },
                { id: 'transformer', name: '箱变', icon: '🏭' },
                { id: 'pcs', name: 'PCS', icon: '🔌' },
                { id: 'power', name: '电源', icon: '🔋' },
                { id: 'locator', name: '定位器', icon: '📍' }
            ],
            data: {
                power: {
                    value: '35.43',
                    trend: 'fall',
                    capacity: '400',
                    todayHours: '3.52'
                },
                daily: {
                    generation: '1370.84',
                    income: '0'
                },
                monthly: {
                    generation: '9929.74',
                    income: '0'
                },
                total: {
                    generation: '36245.03',
                    income: '0'
                }
            },
            customData: {
                power: {
                    value: '42.15',
                    trend: 'rise',
                    capacity: '400',
                    todayHours: '4.2'
                },
                daily: {
                    generation: '1580.25',
                    income: '632.10'
                }
            },
            activeName: 'overview',
            solarPanelUrl: require('@/assets/images/solar_panel.png'),
            inverterUrl: require('@/assets/images/inverter.png'),
            wireBracketUrl: require('@/assets/images/wire_bracket.png'),
            homeUrl: require('@/assets/images/home.png'),
            solarPanelImageUrl: require('@/assets/images/plantImg-default.jpeg'),
            // 电量数据统计时间类型
            typeOfElectricity: '日',
            timeDate: '2025-10-11',
            timeType: 'date',
            dates: null,
            stationId: 'stationId'
        }
    },
    mounted() {
        // 模拟实时数据更新
        this.updateData()
    },
    beforeDestroy() {
        if (this.updateTimer) {
            clearInterval(this.updateTimer)
        }
    },
    methods: {
        toggleNode(nodeId) {
            this.expandedNodes[nodeId] = !this.expandedNodes[nodeId]
        },

        selectDevice(device) {
            this.selectedDevice = device.id
            this.selectedDeviceData = device
            console.log(this.selectedDevice);

        },
        // 更新数据的方法，可以从父组件调用
        updateData(newData) {
            this.data = { ...this.data, ...newData }
        },

        // 设置电价并重新计算收益
        setElectricityPrice(price) {
            this.data.daily.income = (parseFloat(this.data.daily.generation) * price).toFixed(2)
            this.data.monthly.income = (parseFloat(this.data.monthly.generation) * price).toFixed(2)
            this.data.total.income = (parseFloat(this.data.total.generation) * price).toFixed(2)
        },
        // 标签页切换
        handleClick(tab, event) {
            // console.log(tab);
        },
        // 选择切换到电站详情信息模块
        handlerChargeStation() {
            this.selectedDevice = 'stationId'
        },
        // 时间选择绑定值变化时触发的事件
        handleChangeTimeType(timetype) {
            console.log(timetype);
            switch (timetype) {
                case '日':
                    this.timeType = 'date';
                    this.dates = this.getToday24HoursDisplay();
                    break;
                case '月':
                    this.timeType = 'month';
                    this.dates = this.getCurrentMonthDaysArray();
                    break;
                case '年':
                    this.timeType = 'year';
                    this.dates = this.getCurrentYearMonthsArray();
                    break;
                case '总':
                    this.timeType = null;
                    const currentYear = new Date().getFullYear();
                    this.dates = this.getYearsRange(currentYear - 7, currentYear);
                    break;

                default:
                    break;
            }
            console.log(this.dates);

        }
    }
}
</script>

<style scoped lang="scss">
.equipment-tree-container {
    /* width: 300px; */
    /* height: 600px; */
    background: #f5f7fa;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
}

.header {
    background: #409eff;
    color: white;
    padding: 16px;
    text-align: center;

    &:hover {
        cursor: pointer;
    }
}

.header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.equipment-tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.tree-node {
    margin-bottom: 4px;
}

.node-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid #e4e7ed;
}

.node-header:hover {
    background: #f0f7ff;
    border-color: #409eff;
}

.node-icon {
    font-size: 16px;
    margin-right: 8px;
}

.node-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #303133;
}

.device-count {
    font-size: 12px;
    color: #909399;
}

.collapse-icon {
    font-size: 10px;
    color: #909399;
    transition: transform 0.3s;
}

.collapse-icon.rotated {
    transform: rotate(180deg);
}

.node-children {
    margin-left: 24px;
    margin-top: 4px;
}

.device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    margin-bottom: 2px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e4e7ed;
    cursor: pointer;
    transition: all 0.3s;
}

.device-item:hover {
    background: #f0f7ff;
    border-color: #409eff;
}

.device-item.active {
    background: #ecf5ff;
    border-color: #409eff;
}

.device-sn {
    font-size: 12px;
    color: #606266;
    font-family: 'Courier New', monospace;
}

.device-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #67c23a;
}

.device-status.normal {
    background: #67c23a;
}

.device-status.warning {
    background: #e6a23c;
}

.device-status.offline {
    background: #f56c6c;
}

.empty-device {
    text-align: center;
    padding: 12px;
    color: #909399;
    font-size: 12px;
    background: white;
    border-radius: 4px;
    border: 1px dashed #dcdfe6;
}

.selected-info {
    background: white;
    border-top: 1px solid #e4e7ed;
    padding: 16px;
}

.selected-info h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #303133;
    font-weight: 500;
}

.info-content {
    font-size: 12px;
}

.info-item {
    display: flex;
    margin-bottom: 6px;
}

.info-item label {
    color: #909399;
    min-width: 60px;
}

.info-item span {
    color: #303133;
    font-weight: 500;
}

.info-item span.normal {
    color: #67c23a;
}

.info-item span.warning {
    color: #e6a23c;
}

.info-item span.offline {
    color: #f56c6c;
}

/* 滚动条样式 */
.equipment-tree::-webkit-scrollbar {
    width: 6px;
}

.equipment-tree::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.equipment-tree::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.equipment-tree::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.data-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    /* padding: 20px; */
}

.data-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    position: relative;
    overflow: hidden;
}

.data-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.data-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.6) 50%, transparent 100%);
}

/* 卡片颜色主题 */
.power-card {
    border-left-color: #409eff;
    background: linear-gradient(135deg, #f0f7ff 0%, #ffffff 100%);
}

.power-card::before {
    background: linear-gradient(90deg, transparent 0%, #409eff 50%, transparent 100%);
}

.daily-card {
    border-left-color: #67c23a;
    background: linear-gradient(135deg, #f0f9eb 0%, #ffffff 100%);
}

.daily-card::before {
    background: linear-gradient(90deg, transparent 0%, #67c23a 50%, transparent 100%);
}

.monthly-card {
    border-left-color: #e6a23c;
    background: linear-gradient(135deg, #fdf6ec 0%, #ffffff 100%);
}

.monthly-card::before {
    background: linear-gradient(90deg, transparent 0%, #e6a23c 50%, transparent 100%);
}

.total-card {
    border-left-color: #f56c6c;
    background: linear-gradient(135deg, #fef0f0 0%, #ffffff 100%);
}

.total-card::before {
    background: linear-gradient(90deg, transparent 0%, #f56c6c 50%, transparent 100%);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #303133;
    position: relative;
}

.card-title::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 20px;
    height: 2px;
    background: currentColor;
    opacity: 0.6;
}

.card-unit {
    font-size: 12px;
    color: #909399;
    background: rgba(144, 147, 153, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
}

.card-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.main-value {
    font-size: 36px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 数值颜色 */
.power-card .main-value {
    color: #409eff;
}

.daily-card .main-value {
    color: #67c23a;
}

.monthly-card .main-value {
    color: #e6a23c;
}

.total-card .main-value {
    color: #f56c6c;
}

.trend-indicator {
    font-size: 20px;
    font-weight: normal;
}

.trend-indicator.rise {
    color: #67c23a;
}

.trend-indicator.fall {
    color: #f56c6c;
}

.value-unit {
    font-size: 16px;
    color: #909399;
    font-weight: normal;
}

.card-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item .label {
    font-size: 12px;
    color: #909399;
}

.detail-item .value {
    font-size: 14px;
    font-weight: 500;
    color: #303133;
}

.time-info {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(64, 158, 255, 0.1);
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid rgba(64, 158, 255, 0.2);
}

.time-label {
    font-size: 12px;
    color: #409eff;
}

.time-value {
    font-size: 14px;
    font-weight: 600;
    color: #409eff;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .data-cards-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .data-cards-container {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 16px;
    }

    .data-card {
        padding: 20px;
    }

    .main-value {
        font-size: 28px;
    }

    .card-header {
        margin-bottom: 16px;
    }
}

/* 加载状态 */
.data-card.loading .main-value,
.data-card.loading .detail-item .value {
    color: transparent;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.weather-power-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    line-height: 1.4;
}


/* 天气部分样式 */
.weather-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.weather-today {
    display: flex;
    justify-content: space-between;
    /* align-items: center; */
    margin-bottom: 12px;
}

.temperature-range {
    font-size: 18px;
    font-weight: 600;
    color: #303133;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.weather-info {
    font-size: 14px;
    color: #606266;
}

.date {
    font-weight: 500;
}

.weather {
    color: #409eff;
}

.weather-detail {
    margin-bottom: 16px;
    flex: 2;
}

.wind-info {
    font-size: 13px;
    color: #909399;
    margin-bottom: 4px;
}

.timestamp {
    font-size: 12px;
    color: #c0c4cc;
}

.future-weather {
    display: flex;
    /* gap: 10px; */
}

.future-item {
    /* flex: 1; */
    width: 120px;
    text-align: center;
}

.temp-range {
    font-size: 14px;
    font-weight: 500;
    color: #303133;
    margin-bottom: 4px;
}

.weather-desc {
    font-size: 12px;
    color: #606266;
}

/* 电力部分样式 */
.power-section {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 12px;
    position: relative;
}

.power-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.power-value {
    font-size: 16px;
    font-weight: 600;
    color: #e6a23c;
}

.power-percentage {
    font-size: 14px;
    font-weight: 500;
    color: #67c23a;
    background: #f0f9ff;
    padding: 4px 8px;
    border-radius: 4px;
}

.power-solar {
    position: relative;
}

.power-line {
    position: absolute;
    top: calc(50% - 2px);
    right: none;
    bottom: none;
    left: 180px;
    width: calc(36% - 100px);
    height: 2px;
    background: #00b974;

    .power-line-inner {
        position: absolute;
        animation: pvToDevice 4s linear infinite forwards;
    }

    .power-line-inner::before {
        content: "▼";
        color: #00b974;
    }
}

@keyframes pvToDevice {
    from {
        transform: rotate(-90deg);
        top: -10px;
        left: 0;
    }

    to {
        transform: rotate(-90deg);
        top: -10px;
        left: 220px;
    }
}

@keyframes pvToHorizontal {
    0% {
        transform: rotate(-90deg);
        top: -10px;
        left: 0;
    }

    100% {
        transform: rotate(-90deg);
        top: -10px;
        left: 145px;
    }
}

@keyframes pvToHorizontal1 {
    0% {
        transform: rotate(-90deg);
        top: -10px;
        left: 0;
    }

    100% {
        transform: rotate(-90deg);
        top: -10px;
        left: 270px;
    }
}

@keyframes pvToOrdinate1 {
    0% {
        transform: rotate(0deg);
        top: -10px;
        left: -8px;
    }

    50% {
        transform: rotate(0deg);
        top: 60px;
        left: -8px;
    }

    100% {
        transform: rotate(-90deg);
        top: 60px;
        left: 60px;
    }
}

.power-line1 {
    position: absolute;
    top: calc(50% - 2px);
    right: none;
    bottom: none;
    left: calc(56% - 6px);

    .power-line1-horizontal {
        position: absolute;
        left: 0;
        width: 150px;
        height: 2px;
        background: #00b974;
    }

    .power-line1-horizontal1 {
        position: absolute;
        left: 0;
        width: 270px;
        height: 2px;
        background: #00b974;
    }

    .power-line1-horizontal-inner {
        position: absolute;
        animation: pvToHorizontal 3s linear infinite forwards;
    }

    .power-line1-horizontal-inner::before {
        content: "▼";
        color: #00b974;
    }

    .power-line1-horizontal-inner1 {
        position: absolute;
        animation: pvToHorizontal1 3s linear infinite forwards;
    }

    .power-line1-horizontal-inner1::before {
        content: "▼";
        color: #00b974;
    }

    .power-line1-ordinate {
        position: absolute;
        bottom: 0px;
        left: 150px;
        width: 70px;
        height: 70px;
        border-left: 2px solid #00b974;
        border-top: 2px solid #00b974;
        border-top-left-radius: 10px;
    }

    .power-line1-ordinate1 {
        position: absolute;
        left: 150px;
        width: 70px;
        height: 70px;
        border-left: 2px solid #00b974;
        border-bottom: 2px solid #00b974;
        border-bottom-left-radius: 10px;
    }

    .power-line1-ordinate1-inner {
        position: absolute;
        animation: pvToOrdinate1 3s linear infinite forwards;
    }

    .power-line1-ordinate1-inner::before {
        content: "▼";
        color: #00b974;
    }
}

.power-wire {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
}

.power-image {
    width: 135px;
    height: 135px;
    z-index: 2;
}

// 光伏板信息
.solar-panel-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    // font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    justify-content: center;
    color: #666666;

    div {
        padding: 5px 0;
    }

    span {
        color: #000;
    }

    .solar-panel-image {
        width: 100%;
        height: 150px;
    }
}

// 电量数据统计信息
.time_type {
    display: flex;
    align-items: center;
    gap: 20px;
}

.power_generate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
}

.time-line-info {
    display: flex;
    justify-content: center;
    align-items: center;
}

.time-line {
    width: 5px;
    height: 200px;
    background: #909399;
    border-radius: 50%;
}

.reverse-flow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #606266;
}

.reverse-flow-text {
    color: #909399;
}

.reverse-flow-value {
    color: #409eff;
    font-weight: 500;
}

.power-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f5f7fa;
    border-radius: 6px;
    border: 1px solid #e4e7ed;
}

.power-zero {
    font-size: 13px;
    color: #c0c4cc;
}

.power-current {
    font-size: 14px;
    font-weight: 600;
    color: #e6a23c;
}

// 环保收益
.environmental {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.environmental_image {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.environmental_content {
    display: flex;
    align-items: center;
    height: 80px;


    span {
        font-size: 18px;
        font-weight: 600;
    }
}

.environmental_text {
    font-style: 18px;
    color: #000;
    font-weight: 700;
}

.environmental_img_text {
    display: flex;
    flex-direction: column;
    margin-left: 20px;
}

// 报警信息
.alarm_info_text {
    display: flex;
    justify-content: space-between;

    .alarm_title {
        font-size: 20px;
        color: #000;
        font-weight: 700;
    }
}

.alarm_info_detail {
    display: flex;
    flex-direction: column;
    margin: 5px 0;
    background: #f5f5f5;
    padding: 10px 20px !important;
}

.alarm_tags {
    display: flex;
    align-items: center;

    .el-tag {
        border-radius: 20px;
        color: #1890ff !important;
    }
}

.alarm_tags_text {
    margin-left: 20px;
    font-size: 14px;
    font-weight: 700;
}
</style>